let gulp = require("gulp");
let fs = require("fs-extra");
let path = require("path");


exports.default = (done)=>{

    const exec = require("child_process").exec,
    tsc = exec('tsc');

    tsc.stdout.on('data',function (data) {
        console.log(data);
    });

    tsc.on('exit',(code)=>{
        const tsPath = path.join(__dirname,"tsconfig.json");
     
        const tsCfg = fs.readJSONSync(tsPath);
        const outDir = tsCfg['compilerOptions']['outDir'];
        const fileName = "package.json";
        const outFile = path.join(outDir,fileName);
        console.log("outFile:%s",outFile);
        fs.copyFileSync(fileName,outFile);
    });

    done();
};